<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务，帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件，不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);

namespace app\common\model\learn\article;

use cores\BaseModel;

/**
 * 书籍模型
 * Class Category
 * @package app\common\model
 */
class Title extends BaseModel {
	// 定义表名
	protected $name = 'learn_article_title';
	// 定义主键
	protected $pk = 'article_id';

	/**
	 * 分类详情
	 * @param int|array $where
	 * @param array $with
	 * @return static|array|null
	 */
	public static function detail($where, array $with = []) {
		return static::get($where, $with);
	}
	public function getWordAttr($value): string {
		return htmlspecialchars_decode($value);
	}
	public function getPreAttr($value): string {
		return htmlspecialchars_decode($value);
	}
	public function getAbstractAttr($value): string {
		return htmlspecialchars_decode($value);
	}
	public function getExplainAttr($value): string {
		return htmlspecialchars_decode($value);
	}

	/**
	 * 过滤不存在的分类ID集
	 * @param array $categoryIds
	 * @param int|null $storeId
	 * @return array
	 */
	public static function filterCategoryIds(array $categoryIds, int $storeId = null): array {
		return (new static )->where('category_id', 'in', $categoryIds)
			->where('store_id', '=', $storeId ?: self::$storeId)
			->column('category_id');
	}


}
